package cn.tedu.review;

public class TestAnimal {
    public static void main(String[] args) {

        Bird b=new Bird();
        System.out.println("鸟类一般有"+b.legNum+"条腿");
        b.eggNum=8;
        System.out.println("下蛋数"+b.eggNum);
        b.fly();
        b.layEggs();
        System.out.println("_____________");

        Pigeon p=new Pigeon();
        System.out.println("燕子有"+p.legNum+"条腿");
        System.out.println("下蛋数"+p.eggNum);
        p.fly();
        p.layEggs();
        System.out.println("_____________");

        Swallow s=new Swallow();
        System.out.println("燕子有"+s.legNum+"条腿");
        System.out.println("下蛋数"+s.eggNum);
        s.layEggs();
        s.fly();
        s.makeNest();
        System.out.println("_____________");
    }
}
class Bird{
    int legNum=2;
    int eggNum;
    public void fly(){
        System.out.println("鸟类都会飞");
    }
    public void layEggs(){
        System.out.println("鸟类属于蛋生的非哺乳动物");
    }
}
class Pigeon extends Bird{
    public void fly(){
        System.out.println("鸽子记得飞行路线");
    }
    public void layEggs(){
        System.out.println("鸽子蛋很小");

    }
}
class Swallow extends Bird{
    public void fly(){
        System.out.println("燕子飞起来很好看");
    }
    public void layEggs(){
        System.out.println("燕子蛋没见过");
    }
    public void makeNest(){
        System.out.println("燕子会筑巢");
    }
}